package cate.game.role.bag.gem;

import cate.common.table.d.GDObj;
import cate.common.table.item.gem.row.GemBaseRow;
import cate.game.GameBody;
import cate.game.play.support.PlayBuildContext;
import cate.game.role.Role;
import cate.game.role.bag.hero.Hero;
import cate.game.role.bag.item.BaseBagItem;
import com.fasterxml.jackson.annotation.JsonIgnore;
import cp.solution.pattern.ICopiable;
import easy.java.dev.note.NoteClass;

import java.util.HashSet;
import java.util.Set;

@NoteClass(value = "宝石")
public class Gem extends BaseBagItem implements ICopiable<Gem> {
    public Gem(){}

    public Gem(Role role, int tid, long num){
        super(role, GDObj.Type.GEM, tid, num);
    }

    @JsonIgnore
    public Set<Integer> getSkills(PlayBuildContext ctx, Hero owner) {
        Set<Integer> skills = new HashSet<>();
        GemBaseRow row = getTpl(ctx);
        if (owner == null || row == null) {
            return skills;
        }
        if (row.effectJobs.contains(owner.getTpl(ctx).job)) {
            skills.add(row.skillId);
        }
        // 专属英雄穿戴才有技能
        return skills;
    }

    @Override
    @JsonIgnore
    public GemBaseRow getTpl(PlayBuildContext ctx) {
        return ctx.gemExcel().base.get(tid);
    }

    @Override
    public GemBaseRow getTpl(GameBody game) {
        return getTpl(game.fight.getPlayBuildContext());
    }

    @Override
    public Gem copy() {
        Gem cp = new Gem();
        super.copy(cp);
        return cp;
    }

    @Override
    public String toDetail() {
        return "";
    }
}
